Repository navigation
fix: admin sign-in applies the same account checks as the regular sign-in - #472
Merged
Merged
Conversation
…n-in The admin sign-in route now refuses accounts pending approval and rejected accounts with the same responses the regular local sign-in gives, and answers a deleted account like a wrong password. The registration check is shared with LocalAuthProvider. The setup admin, approved users and older rows with no registration status still sign in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
POST /api/auth/admin/login(src/app/api/auth/admin/login/route.ts) now checks the account after the password matches and before it recordslastLoginAtor issues tokens:{ success: false, pendingApproval: true, message }the regular local sign-in returns, so the login page shows its "Account Pending Approval" notice;{ error: 'Account has been rejected' }the regular local sign-in returns;deletedAtset): the same 401 as an unknown user or a wrong password.src/lib/services/auth/local-account-status.tsholds the registration check and its two messages.LocalAuthProvider(sign-in andvalidateAccess) and the local login route now use it too, with no change in what they return.documentation/backend/services/auth.md(Local Admin Authentication: account checks; one Fixed Issues line).Why
The admin sign-in now applies the same account checks as the regular sign-in.
Evidence
tests/api/auth-admin-login.routes.test.ts, six new route tests: pending, rejected and deleted rows get no tokens, no token calls and nolastLoginAtupdate, each with the regular sign-in's response; the setup admin (Plex mode,isSetupAdmin), an approved local user and an older row with a nullregistrationStatusstill sign in and getlastLoginAtupdated.main's route and this branch's test file: 3 failed, 9 passed, each on a status or body assertion in the three refused cases. On this branch: 12/12 pass.approved: the setup wizard writes it for the setup admin in both modes, registration writes it for the first user and whenever approval isn't required, and approving a user sets it. The column defaults toapproved, so rows from before it existed got that value. Null is only possible from a manual write; it is treated as approved, as the regular sign-in does.Checks
vitest relatedon the four changed source files, plus the test file): PASS, 6 files, 78/78tsc --noEmitclean; ESLint on the 5 touched files reports nothing new compared withmain)--specs smoke): PASS (imagermab-e2e/t65:07c2e3b, 1/1 smoke spec passed; stack and images removed)main(5f0aa4e):vitest relatedon the source changed on both sides: PASS, 137 files, 1978/1978;tsc --noEmitcleanRisk and rollback
rejectedis not written by any current path (rejecting a pending user removes the row). Deleted accounts are refused ondeletedAt.Release note
🤖 Generated with Claude Code